{% block sw_product_stream_list %}
<sw-page class="sw-product-stream-list">

    {% block sw_product_stream_list_search_bar %}
    <template #search-bar>
        <sw-search-bar
            initial-search-type="product_stream"
            :placeholder="$tc('sw-product-stream.general.placeholderSearchBar')"
            :initial-search="term"
            @search="onSearch"
        />
    </template>
    {% endblock %}

    {% block sw_product_stream_list_smart_bar_header %}
    <template #smart-bar-header>
        {% block sw_product_stream_list_smart_bar_header_title %}
        <h2>
            {% block sw_product_stream_list_smart_bar_header_title_text %}
            {{ $tc('sw-product-stream.list.textProductStreamOverview') }}
            {% endblock %}

            {% block sw_product_stream_list_smart_bar_header_amount %}
            <span
                v-if="!isLoading"
                class="sw-page__smart-bar-amount"
            >
                ({{ total }})
            </span>
            {% endblock %}
        </h2>
        {% endblock %}
    </template>
    {% endblock %}

    {% block sw_product_stream_list_smart_bar_actions %}
    <template #smart-bar-actions>
        {% block sw_product_stream_list_smart_bar_actions_add %}
        <mt-button
            v-tooltip.bottom="getNoPermissionsTooltip('product_stream.creator')"
            class="sw-product-stream-list__create-action"
            :disabled="!acl.can('product_stream.creator')"
            variant="primary"
            size="default"
            @click="$router.push({ name: 'sw.product.stream.create' })"
        >
            {{ $tc('sw-product-stream.list.buttonAddProductStream') }}
        </mt-button>
        {% endblock %}
    </template>
    {% endblock %}

    {% block sw_manufacturer_list_language_switch %}
    <template #language-switch>
        <sw-language-switch @on-change="onChangeLanguage" />
    </template>
    {% endblock %}

    <template #content>

        {% block sw_product_stream_list_content %}
        <div class="sw-product-stream-list__content">

            {% block sw_product_stream_list_empty_state %}
            <mt-empty-state
                v-if="!isLoading && !total"
                :centered="true"
                :icon="$route.meta.$module.icon"
                :headline="isValidTerm(term) ? $t('sw-empty-state.messageNoResultTitle') : $t('sw-product-stream.list.messageEmpty')"
                :description="isValidTerm(term) ? $t('sw-empty-state.messageNoResultSubline') : $t($route.meta.$module.description)"
                :link-text="isValidTerm(term) ? $t('sw-empty-state.messageNoResultLink') : ''"
                :link-href="isValidTerm(term) ? $router.resolve({ name: 'sw.profile.index.searchPreferences' }).href : ''"
            />
            {% endblock %}

            {% block sw_product_stream_list_grid %}
            <sw-entity-listing
                v-else-if="isLoading || (productStreams && entitySearchable)"
                ref="swProductStreamGrid"
                class="sw-product-stream-list-grid"
                :items="productStreams"
                :columns="getProductStreamColumns()"
                :repository="productStreamRepository"
                detail-route="sw.product.stream.detail"
                :show-selection="acl.can('product_stream.deleter')"
                :is-loading="isLoading"
                :disable-data-fetching="true"
                :sort-by="currentSortBy"
                :sort-direction="sortDirection"
                :criteria-limit="limit"
                :allow-inline-edit="acl.can('product_stream.editor')"
                identifier="sw-product-stream-list"
                @page-change="onPageChange"
                @column-sort="onSortColumn"
                @inline-edit-save="onInlineEditSave"
                @items-delete-finish="getList"
                @delete-item-failed="onDeleteItemFailed"
                @delete-items-failed="onDeleteItemsFailed"
            >

                {% block sw_product_stream_list_grid_bulk %}
                <template #bulk>
                    <span v-if="!acl.can('product_stream.deleter')"></span>
                </template>
                {% endblock %}

                {% block sw_product_stream_list_grid_column_invalid %}
                <template #column-invalid="{item}">
                    <template v-if="item.invalid">
                        {{ $tc('sw-product-stream.list.status.invalid') }}
                    </template>

                    <template v-else>
                        {{ $tc('sw-product-stream.list.status.valid') }}
                    </template>
                </template>
                {% endblock %}

                {% block sw_product_stream_list_grid_colum_updated_at %}
                <template #column-updatedAt="{item}">
                    <template v-if="item.updatedAt">
                        <sw-time-ago :date="item.updatedAt" />
                    </template>
                    <template v-else>
                        <sw-time-ago :date="item.createdAt" />
                    </template>
                </template>
                {% endblock %}

                {% block sw_product_stream_list_grid_more_actions %}
                <template #more-actions="{item}">
                    {% block sw_product_stream_list_grid_duplicate_action %}
                    <sw-context-menu-item
                        :disabled="!acl.can('product_stream.creator')"
                        class="sw-entity-listing__context-menu-edit-duplicate"
                        @click="onDuplicate(item)"
                    >
                        {{ $tc('global.default.duplicate') }}
                    </sw-context-menu-item>
                    {% endblock %}
                </template>
                {% endblock %}

                {% block sw_product_stream_list_grid_delete_action %}
                <template #delete-action="{item, showDelete, allowDelete}">

                    <sw-context-menu-item
                        :disabled="!acl.can('product_stream.deleter') || !allowDelete"
                        class="sw-entity-listing__context-menu-edit-delete"
                        variant="danger"
                        @click="showDelete(item.id)"
                    >
                        {{ $tc('global.default.delete') }}
                    </sw-context-menu-item>
                </template>
                {% endblock %}
            </sw-entity-listing>
            {% endblock %}
        </div>
        {% endblock %}
    </template>

    {% block sw_product_stream_list_sidebar %}
    <template #sidebar>
        <sw-sidebar>

            {% block sw_product_stream_list_sidebar_refresh %}
            <sw-sidebar-item
                icon="regular-undo"
                :title="$tc('sw-product-stream.list.titleSidebarItemRefresh')"
                @click="onRefresh"
            />
            {% endblock %}
        </sw-sidebar>
    </template>
    {% endblock %}

</sw-page>
{% endblock %}
